﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Awesomium.Core;
using Awesomium.Windows.Controls;

namespace KinectControls
{
    class MenuMapItem
    {
        #region instance variables
        
        private char _mapLetter;
        private string _name;
        private string _shortDesc;
        private string _mapId;
        private string _overlayCall;
        private string _imageUrl;
        private WebControl _map;

        #endregion

        #region Getters and Setters

        public string mapLetter
        {
            // return empty string if we are passed letter Z
            // this is how the webapp handles it (as far as I could tell)
            get { return (_mapLetter > 'Z') ? "" : ""+this._mapLetter; }
            set { 
                this._mapLetter = value.ToCharArray()[0];
                this._imageUrl = "http://maps.rit.edu/images/markers/dk-blue_Marker" + 
                    mapLetter + ".png?v1.1.1";
            }
        }

        public string name { 
            get { return this._name; }
            set { this._name = value; }
        }

        public string shortDesc { 
            get { return this._shortDesc; }
            set { this._shortDesc = value; }
        }

        public string mapId
        {
            get { return this._mapId; }
            set 
            { 
                this._mapId = value;
                this._overlayCall = "displayMDOInfo(" + mapId + ", 'marker')";
            }
        }

        public string overlayCall
        {
            get { return this._overlayCall; }
        }

        public string imageUrl
        {
            get { return this._imageUrl; }
        }

        public WebControl map
        {
            set { this._map = value; }
        }

        #endregion

        #region events

        public void button_Click(object sender, EventArgs e)
        {
            _map.ExecuteJavascript(this._overlayCall);
            _map.ExecuteJavascript("$(\".info-window-link\").empty();");
        }

        #endregion

    }
}
